package com.avantis.common.entity;

import com.avantis.common.entity.base.BaseEntity;
import com.avantis.common.utils.DateUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @ClassName Notification
 * @Description 用户通知
 * @Author kirago
 * @Date 2018/11/26 19:16
 * @Version 1.0
 **/
@Entity
@Table(name = "k_notification")
@Data
public class Notification extends BaseEntity implements Serializable {

	//通知是否已读
	@Column(name = "is_read")
	private boolean isRead = false;

	//要通知的用户：立即加载
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(nullable = false)
	private User toUser;

	//发起通知的用户
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(nullable = false)
	private User fromUser;

//	@ManyToOne(fetch = FetchType.EAGER)
//	@JoinColumn(nullable = false,name = "posts_id")
//	private Posts posts;

	//发布时间
	@Column(nullable = false)
	@JsonFormat(pattern = DateUtils.DEFAULT_DATETIME_FORMAT, timezone = "GMT+8")
	private Date initTime;

}
